$(function () {
    main.init();
});
(function ($) {
        $.extend(
            main = {
                e_template_i : {
                    color : ['rgb(91,228,250)'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            label: {
                                backgroundColor: '#6a7985'
                            }
                        }
                    },
                    legend: {
                        data: ['新员工录入数量']
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            boundaryGap: false,
                            data: []
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            name: '新员工录入数量',
                            type: 'line',
                            stack: 'Total',
                            smooth: true,
                            lineStyle: {
                                width: 1
                            },
                            showSymbol: false,
                            areaStyle: {
                                opacity: 0.8,
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                    {
                                        offset: 0,
                                        color: 'rgb(55,162,255)'
                                    },
                                    {
                                        offset: 1,
                                        color: 'rgb(116, 21, 219)'
                                    }
                                ])
                            },
                            emphasis: {
                                focus: 'series'
                            },
                            data: []
                        }
                    ]
                },
                e_template_s : {
                    color : ['rgb(236,116,202)'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            label: {
                                backgroundColor: '#6a7985'
                            }
                        }
                    },
                    legend: {
                        data: ['短信下发数量']
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            boundaryGap: false,
                            data: []
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            name: '短信下发数量',
                            type: 'line',
                            stack: 'Total',
                            smooth: true,
                            lineStyle: {
                                width: 1
                            },
                            showSymbol: false,
                            areaStyle: {
                                opacity: 0.8,
                                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                    {
                                        offset: 0,
                                        color: 'rgb(255,132,128)'
                                    },
                                    {
                                        offset: 1,
                                        color: 'rgb(1,236,154)'
                                    }
                                ])
                            },
                            emphasis: {
                                focus: 'series'
                            },
                            data: []
                        },
                    ]
                },
                //初始化
                init : ()=>{
                    let e_i = echarts.init(document.getElementById('echarts_i'));
                    let e_s = echarts.init(document.getElementById('echarts_s'));
                    main.getHeadCountData((r) => {
                        let i = main.e_template_i;
                        let s = main.e_template_s;
                        i.xAxis[0].data = r.date;
                        i.series[0].data = r.data_i;
                        s.xAxis[0].data = r.date;
                        s.series[0].data = r.data_s;
                        e_i.setOption(i);
                        e_s.setOption(s);
                    });
                },
                //获取首页数据
                getHeadCountData : (callback) => {
                    $.ajax({
                        type : "GET",
                        async : false,
                        url : "/ry/rnx/count/headCount",
                        dataType : "json",
                        cache : false,
                        contentType : "application/json;charset=UTF-8",
                        success : function(r) {
                            callback(r.data);
                        }
                    });
                },
            }
        )
    }
)($);